package gjw.photodialog;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

/**
 * @创建者 Jimven
 * @创建时间 2017/12/27/0027  14:27
 */
public class CodeDialogActivity extends AppCompatActivity implements View.OnClickListener {

    private Button     mBtn_showdialog;
    private CodeDialog mDialog;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_codedialog);
        initView();
        initListener();
        initData();
        initEvent();

    }

    private void initView() {
        mBtn_showdialog = (Button) findViewById(R.id.btn_showdialog);

    }

    private void initListener() {
        mBtn_showdialog.setOnClickListener(this);

    }

    private void initData() {

    }

    private void initEvent() {
    }

    @Override
    public void onClick(View view) {
        int Id = view.getId();
        switch (Id) {
            case R.id.btn_showdialog://显示dialog
                Toast.makeText(CodeDialogActivity.this, "onClick", Toast.LENGTH_SHORT).show();
                getCode();

                break;
            default:
                break;
        }

    }

    private void getCode() {
        mDialog = new CodeDialog(this, R.style.CodeDialog, new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                int Id = view.getId();
                switch (Id) {
                    case R.id.recriver_code:
                        // TODO: 2017/12/27/0027 14:38 接收验证码
                        Toast.makeText(CodeDialogActivity.this, "更新验证码", Toast.LENGTH_SHORT).show();
                        break;
                    case R.id.iv_close_dialog:
                        mDialog.dismiss();

                        break;
                    case R.id.btn_check_code:
                        EditText et_input_code = (EditText) mDialog.getWindow().findViewById(R.id.et_input_code);
                        Toast.makeText(CodeDialogActivity.this, et_input_code.getText().toString(), Toast.LENGTH_SHORT).show();
                        break;

                    default:
                        break;
                }

            }
        });
        mDialog.show();
    }
}
